home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / morris / modgen.bas < prev    next >
Encoding:
BASIC Source File  |  1994-11-15  |  5.2 KB  |  216 lines

  1. '==========================================================
  2. '
  3. '    Module - MODGEN.BAS
  4. '
  5. '    Module Prefix - None
  6. '
  7. '    Author - Peter J. Morris. TMS Ltd.
  8. '
  9. '    Date Written : #### Date - 16/11/94    Time - 03:11
  10. '
  11. '    Purpose - Common support module for VBITS demo code.
  12. '
  13. '    Revisions
  14. '    BY            WHY            AFFECTED
  15. '    Peter J. Morris. TMS Ltd. Original code.
  16. '
  17. '==========================================================
  18.  
  19.  
  20. Option Explicit
  21.  
  22. '==========================================================
  23. '
  24. '    Function - DoLabels
  25. '
  26. '    Author - Peter J. Morris. TMS Ltd.
  27. '
  28. '    Date Written: #### Date - 16/11/94    Time - 03:11
  29. '
  30. '    Purpose - See function purpose.
  31. '
  32. '    Revisions:
  33. '    BY            WHY            AFFECTED
  34. '    Peter J. Morris. TMS Ltd. Original code.
  35. '
  36. '
  37. '    INPUTS -  frm -> Form to use.
  38. '
  39. '
  40. '    OUTPUTS - None
  41. '
  42. '==========================================================
  43. Sub DoLabels (frm As Form)
  44. '==========================================================
  45. '
  46. '    Form: MODGEN.BAS Procedure: DoLabels
  47. '
  48. '    Author - Peter J. Morris. TMS Ltd.
  49. '    Template fitted: #### Date - 16/11/94    Time - 03:11
  50. '
  51. '    Copyright and status if any: Copyright ⌐ TMS 1994,1995
  52. '    All rights reserved. Status @BLUE@TMS.DEMO@COLD
  53. '
  54. '    Purpose/Description In brief:
  55. '    Sub used to reset all Label controls on a given form.
  56. '
  57. '=========================================================
  58.  
  59. ' Set up general error handler
  60.  
  61. On Error GoTo Error_DoLabels:
  62.  
  63.     ' ========== Code Starts.==========
  64.  
  65.  
  66.     ' Control variable.
  67.     Dim cp    As Control
  68.     Dim nLoop As Integer
  69.  
  70.     ' For every control 'in' a form do...
  71.     For nLoop = 0 To frm.Controls.Count - 1
  72.         
  73.         Set cp = frm.Controls(nLoop)
  74.  
  75.         ' If it's a label...
  76.         If TypeOf cp Is Label Then
  77.             ' Turn off its border and reset & set AutoResize. This makes sure that
  78.             ' the label is ALWAYS big enough to take its text  irrespective of the
  79.             ' device driver used. BorderStyle = 0 turns off the label's border, we
  80.             ' usually leave on the  label's  border  at design time so that we can
  81.             ' see/place it more easily.
  82.             cp.BorderStyle = 0
  83.             cp.AutoSize = False
  84.             cp.AutoSize = True
  85.         End If
  86.  
  87.     Next
  88.  
  89.  
  90.     ' ========== Code Ends  .==========
  91.  
  92.     Exit Sub
  93.  
  94. ' Error handler
  95. Error_DoLabels:
  96.  
  97.     ' Call general error handler
  98.  
  99.     ErrorHandler "MODGEN.BAS/DoLabels", Err, Error$
  100.  
  101.     ' Default resume behaviour: exit this sub/func
  102.  
  103.     Resume Exit_DoLabels:
  104.  
  105. Exit_DoLabels:
  106.  
  107.  
  108. End Sub
  109.  
  110. '==========================================================
  111. '
  112. '    Function - ErrorHandler
  113. '
  114. '    Author - Peter J. Morris. TMS Ltd.
  115. '
  116. '    Date Written: #### Date - 16/11/94    Time - 03:11
  117. '
  118. '    Purpose - See function purpose.
  119. '
  120. '    Revisions:
  121. '    BY            WHY            AFFECTED
  122. '    Peter J. Morris. TMS Ltd. Original code.
  123. '
  124. '
  125. '    INPUTS -  sModuleInfo -> Name of module and routine in which
  126. '                              error occurred.
  127. '              nErrNo      -> Visual Basic 'Err' error code for error.
  128. '              sErrorText  -> Visual Basic 'Error$' error text for error.
  129. '
  130. '
  131. '    OUTPUTS - None
  132. '
  133. '==========================================================
  134. Sub ErrorHandler (ByVal sModuleInfo As String, ByVal nErrNo As Integer, ByVal sErrorText As String)
  135.  
  136.     ' Report the error.
  137.     MsgBox "An error occurred in " & sModuleInfo & "." & " The error was " & sErrorText, MB_OK Or MB_ICONSTOP, "Error"
  138.  
  139.     ' Treat all errors as fatal in this demo. Terminate the app.
  140.     End
  141.  
  142. End Sub
  143.  
  144. '==========================================================
  145. '
  146. '    Function - CenterWindow
  147. '
  148. '    Author - Peter J. Morris. TMS Ltd.
  149. '
  150. '    Date Written: #### Date - 16/11/94    Time - 03:11
  151. '
  152. '    Purpose - See function purpose.
  153. '
  154. '    Revisions:
  155. '    BY            WHY            AFFECTED
  156. '    Peter J. Morris. TMS Ltd. Original code.
  157. '
  158. '
  159. '    INPUTS -  frm -> Form to use.
  160. '
  161. '
  162. '    OUTPUTS - None
  163. '
  164. '==========================================================
  165. Sub CenterWindow (frm As Form)
  166. '==========================================================
  167. '
  168. '    Form: MODGEN.BAS Procedure: CenterWindow
  169. '
  170. '    Author - Peter J. Morris. TMS Ltd.
  171. '    Template fitted: #### Date - 16/11/94    Time - 03:11
  172. '
  173. '    Copyright and status if any: Copyright ⌐ TMS 1994,1995
  174. '    All rights reserved. Status @BLUE@TMS.DEMO@COLD
  175. '
  176. '    Purpose/Description In brief:
  177. '
  178. '=========================================================
  179.  
  180. ' Set up general error handler
  181.  
  182. On Error GoTo Error_CenterWindow:
  183.  
  184.     ' ========== Code Starts.==========
  185.  
  186.  
  187.     Dim nNewX As Integer
  188.     Dim nNewY As Integer
  189.  
  190.     nNewX = (Screen.Width - frm.Width) / 2
  191.     nNewY = (Screen.Height - frm.Height) / 2
  192.  
  193.     frm.Move nNewX, nNewY
  194.  
  195.  
  196.     ' ========== Code Ends  .==========
  197.  
  198.     Exit Sub
  199.  
  200. ' Error handler
  201. Error_CenterWindow:
  202.  
  203.     ' Call general error handler
  204.  
  205.     ErrorHandler "MODGEN.BAS/CenterWindow", Err, Error$
  206.  
  207.     ' Default resume behaviour: exit this sub/func
  208.  
  209.     Resume Exit_CenterWindow:
  210.  
  211. Exit_CenterWindow:
  212.  
  213.  
  214. End Sub
  215.  
  216.